package com.wang;

import java.util.ArrayList;
import java.util.LinkedList;

/**
 * @ProjectName: untitled
 * @Titile: LinkListDemo
 * @Author: 王亦凡1
 * @Description: TODO
 */
public class LinkedListDemo {
    public static void main(String[] args) {
        LinkedList<String> list=new LinkedList<>();
        list.addFirst("张三");
        list.addLast("王五");
        list.addLast("李四");
        list.addLast("王彪");

        String s=list.get(3);//o(n)查询效率慢
        ArrayList<String>arrayList=new ArrayList<>();
        arrayList.get(3);//o(1)查询效率极快



        String first=list.getFirst();
        System.out.println(first);
        String last=list.getLast();
        System.out.println(last);

        String removeFirst=list.getFirst();
        System.out.println(removeFirst);
        String removeLast=list.removeLast();
        System.out.println(removeLast);

        System.out.println(list);

    }
}
